package com.globallogic.training.vaskulg.binarytree;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

public class NodeTester {
	private Node<String> testNode;
	
	@Before
	public void setUp() throws Exception {
		testNode = new Node<String>("Value");
	}

	@Test
	public void shouldCreateObjectWhenCorrectConstructor() {	
		assertTrue(testNode instanceof Node);
	}

	@Test
	public void shouldSupportAFirstTypeAsTypeOfValue() {
		assertEquals("Value", testNode.getValue());	
	}
	
	@Test
	public void shouldSupportASecondTypeAsTypeOfValue() {
		Node<Integer> integerNode = new Node<Integer>(123);
		
		assertEquals(new Integer(123), integerNode.getValue());
	}
	
	@Test
	public void shouldHaveParentIfParentIsDefined() {
		// Given
		Node<String> parentNode = new Node<String>("Parent");
		
		// When
		testNode.setParent(parentNode);
		
		assertEquals(parentNode, testNode.getParent());
	}
	
	@Test
	public void shouldHaveLeftChildIfTheChildIsDefined() {
		// Given
		Node<String> leftNode = new Node<String>("Left Child");
		
		// When
		testNode.setLeftChild(leftNode);
		
		assertEquals(leftNode, testNode.getLeftChild());
	}
	
	@Test
	public void shouldHaveRightChildIfTheChildIsDefined() {
		// Given
		Node<String> rightNode = new Node<String>("Right Child");
		
		// When
		testNode.setRightChild(rightNode);
		
		assertEquals(rightNode, testNode.getRightChild());
	}
}
